﻿Public Class Form2

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ' [ファイルの種類] ボックスに表示される選択肢を設定する
        OpenFileDialog1.Filter = "zipファイル(*.zip)|*.zip"

        'ダイアログを表示
        If OpenFileDialog1.ShowDialog = DialogResult.OK Then
            TextBox1.Text = OpenFileDialog1.FileName
        End If

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If ListBox1.SelectedItem = "" Then
            MsgBox("必ず選択してください")
        ElseIf ListBox1.SelectedItem = "MML形式" Then
            If CheckBox1.Checked = True Then
                My.Computer.Network.DownloadFile( _
            TextBox1.Text, Application.StartupPath & TextBox2.Text & "\tenp\modpak.zip", _
            "username", "password", _
            True, 60000, True, FileIO.UICancelOption.DoNothing)
            Else
                System.IO.File.Copy(TextBox1.Text, Application.StartupPath & TextBox2.Text & "\tenp\modpak.zip")
            End If
            Dim zipFileName As String = Application.StartupPath & TextBox2.Text & "\tenp\modpak.zip"
            Dim targetDirectory As String = Application.StartupPath & TextBox2.Text & "\tenp\zip"
            Dim fileFilter As String = ""
            Dim fastZip As New ICSharpCode.SharpZipLib.Zip.FastZip()
            fastZip.RestoreAttributesOnExtract = True
            fastZip.RestoreDateTimeOnExtract = True
            fastZip.CreateEmptyDirectories = True
            fastZip.ExtractZip(zipFileName, targetDirectory, fileFilter)
        ElseIf ListBox1.SelectedItem = "multiMC形式" Then
            MsgBox("未実装です！")
        ElseIf ListBox1.SelectedItem = "mcnowmodinstaller形式" Then
            MsgBox("未実装です！")
        End If
        
    End Sub

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        
    End Sub
End Class